<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>修改发货状态</title>

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/bootstrap.min.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/fonts/line-icons.css}">

    <link rel="stylesheet" th:href="@{/assets/plugins/morris/morris.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/main.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/responsive.css}">

    <script type="text/javascript" th:inline="javascript">

    </script>
</head>
<body>
<div class="app header-default side-nav-dark">
    <div class="layout">

        <div class="page-container pl-0">
            <div class="main-content">
                <div class="container-fluid">
                    <div class="card">
                        <div class="card-header border-bottom">
                            <h4 class="card-title">订单信息</h4>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-lg-10 col-md-12 col-xs-12">
                                    <div role="form" id="form-validation" novalidate="novalidate" th:object="${order}" method="post" action="/admin/order/updateOrderConsignStatus">
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">订单编号</label>
                                            <div class="col-sm-10">
                                                <div th:if="${order!=null}">
                                                    <input type="text" th:value="*{id}" class="form-control" disabled="disabled" name="orderId" placeholder="订单编号">
                                                </div>
                                                <div th:if="${order==null}">
                                                    <input type="text" class="form-control" name="orderId" placeholder="订单编号">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">物流名称</label>
                                            <div class="col-sm-10">
                                                <div th:if="${order!=null}">
                                                    <select id="shippingName" class="form-control custom-select chosen"
                                                            required style="color: #232323;">
                                                        <option value="菜鸟">菜鸟</option>
                                                        <option value="顺丰">顺丰</option>
                                                        <option value="中通">中通</option>
                                                        <option value="圆通">圆通</option>
                                                        <option value="韵达">韵达</option>
                                                    </select>
<!--                                                    <input type="text" th:value="*{shippingName}" class="form-control" name="shippingName" placeholder="物流名称">-->
                                                </div>
                                                <div th:if="${order==null}">
                                                    <input type="text" class="form-control" name="shippingName" placeholder="物流名称">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">物流单号</label>
                                            <div class="col-sm-10">
                                                <div th:if="${order!=null}">
                                                    <input type="text" th:value="*{shippingCode}" class="form-control" name="shippingCode" placeholder="物流单号">
                                                </div>
                                                <div th:if="${order==null}">
                                                    <input type="text" class="form-control" name="shippingCode" placeholder="物流单号">
                                                </div>
                                            </div>
                                        </div>
                                        <span th:unless="${order==null}" onclick="updateOrderConsignStatus()"><button type="button" class="btn btn-outline-success">确认发货</button></span>
                                        <div type="text" style="color: red;border-style: none" id="tips" readonly></div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div id="preloader">
    <div class="loader" id="loader-1"></div>
</div>


<script th:src="@{/assets/js/jquery-min.js}"></script>
<script th:src="@{/assets/js/popper.min.js}"></script>
<script th:src="@{/assets/js/bootstrap.min.js}"></script>
<script th:src="@{/assets/js/jquery.app.js}"></script>
<script th:src="@{/assets/js/main.js}"></script>

<script th:src="@{/assets/plugins/morris/morris.min.js}"></script>
<script th:src="@{/assets/plugins/raphael/raphael-min.js}"></script>
<script th:src="@{/assets/js/dashborad1.js}"></script>
<script type="text/javascript">
    $(function () {
        $("#tips").hide();
    });

    function updateOrderConsignStatus(){
        console.log($("#shippingName").val());
        var shippingCode = $("input[name='shippingCode']").val();
        if (shippingCode!=""){
            $.post("updateOrderConsignStatus",
                {"id":$("input[name='orderId']").val(),"shippingName": $("#shippingName").val(),"shippingCode":shippingCode},
                function (data) {
                    if(data!="0"){
                        window.open("/admin/order/getAll","_self");
                    }else {
                        $("#tips").text("* 发货失败");
                        $("#tips").show();
                    }
                }
            )
        }else {
            $("#tips").text("* 物流单号不能为空");
            $("#tips").show();
        }

    }
</script>
</body>

</html>